package com.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.entity.BookOrder;
import com.demo.mapper.BookMapper;
import com.demo.mapper.BookOrderMapper;
import com.demo.service.IBookOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2023-05-09
 */
@Service
public class BookOrderServiceImpl extends ServiceImpl<BookOrderMapper, BookOrder> implements IBookOrderService {
    @Resource
    private BookMapper bookMapper;

    @Override
    public boolean save(BookOrder entity) {
        entity.setStatus(0);
        entity.setOrderId(UUID.randomUUID().toString());
        entity.setMoney(bookMapper.selectById(entity.getBookId()).getPrice());
        return super.save(entity);
    }

    @Override
    public void ajaxBookOrder(BookOrder bookOrder) {

    }
}
